package com.mes.task.dao;

import java.util.Date;
import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.stereotype.Repository;

import com.mes.common.dao.BasicDao;
import com.mes.task.dao.iface.ITaskDao;
import com.mes.task.domain.Task;

@Repository
public class TaskDao extends BasicDao<Task> implements ITaskDao {

	/**
	 * 获取某个任务的最晚反馈时间
	 * @return 
	 */
	public Date getMaxFeedBackDate(String taskUid) throws Exception{
		Date lastDate = new Date();
		Session session = this.getSessionFactory().getCurrentSession();
		String sql = "select nvl(max(workdate),sysdate) as maxworkdate from t_workrec w where w.taskuid=:taskUid";
		Query query = session.createSQLQuery(sql);
		query.setString("taskUid", taskUid);
		lastDate = (Date)query.uniqueResult();
		
		return lastDate;
	}
	
	
	
	
	
	@Override
	public Task getRepairTask(String partUid, String sn) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Task> getOperationStepTask(String partUid, String batchNum) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Task> getTasksByParentTaskUid(String parentTaskUid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<Task> getAOTasksByParentTaskUid(String parentTaskUid) {
		// TODO Auto-generated method stub
		return null;
	}

}
